<?
require_once "db.php";

$title = $_POST['title'];
$ts = $_POST['ts'];
$content = $_POST['content'];

if ($_GET["action"] == "add")
{
    $sql = "insert into headlines (title, ts,content) values ('{$title}', '{$ts}', '{$content}');";
}
else if ($_GET["action"] == "update")
{
    $id = $_POST['id'];
    $sql = "update headlines set title='{$title}', ts='{$ts}', content='{$content}' where id = '{$id}';";
}
else if ($_GET["action"] == "delete")
{
    $id = $_POST['id'];
    $sql = "delete from headlines where id = '{$id}';";
}

$ret = $db->exec($sql);

if ($ret)
{
    echo 200;
}
else
{
    echo 0;
}
